//============================================================================
// Name        : KeywordAurelio.cpp
// Author      : Baggio sl
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include "./support/Hasher.h"
#include "./support/SequencialReadPages.h"
#include "KeywordAurelio.h"
#include "./keywordFinder/KeywordFinder.h"
#include <list>


using namespace std;

int main() {
	
	list< pair<unsigned long long, unsigned long long> > myList;
	KeywordFinder kf;
	KeywordAurelio aurelio;
	SequencialReadPages srp;
	uint j = 0;
	bool blah = true;
	while (blah) {
		cout << "comeco" << endl;
		myList.clear();
		for (uint i = 0; i < 1000 && blah; i++) {
			string page = srp.getPageHTML();
			string url = srp.getPageURL();
			kf.findKeywords(page, url, myList);
			blah = srp.next();
		}
		kf.coutTimes();
		cout << "meio" << endl;
		aurelio.addNewKeywords(myList);
		if (j%200 == 199) {
			cout << "Imprimindo..." << endl;
			aurelio.coutKeywordMap(j/200);
			aurelio.clear();
		}
		cout << "j: " << ++j << endl;
//		aurelio.clear();
	}
	cout << "Imprimindo final..." << endl;
	aurelio.coutKeywordMap(j/200 + 1);
	aurelio.clear();
	cout << "Fim" << endl;
	return 0;
	
	
	
	
	
	
	
	
	
	
	
	
	
//	list< pair<unsigned long long, unsigned long long> > myList;
//
//	myList.push_back(pair<unsigned long long, unsigned long long>(Hasher::abcHash("MC"), 18));
//	myList.push_back(pair<unsigned long long, unsigned long long>(Hasher::abcHash("mto"), 13));
//	myList.push_back(pair<unsigned long long, unsigned long long>(Hasher::abcHash("suga"), 19));
//	myList.push_back(pair<unsigned long long, unsigned long long>(Hasher::abcHash("MC"), 15));
//	myList.push_back(pair<unsigned long long, unsigned long long>(Hasher::abcHash("muuuuito"), 11));
//	myList.push_back(pair<unsigned long long, unsigned long long>(Hasher::abcHash("suga"), 19));
//	myList.push_back(pair<unsigned long long, unsigned long long>(Hasher::abcHash("MC"), 15));
//	myList.push_back(pair<unsigned long long, unsigned long long>(Hasher::abcHash("MC"), 15));
//	
//	KeywordAurelio ka;
//	ka.addNewKeywords(myList);
//	ka.coutKeywordMap();
}
